package org.jeecg.modules.hotel.leave.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.basic.demo.apartment.mapper.LwgyBaseApartmentMapper;
import org.jeecg.modules.hotel.arrangement.entity.LwgyHotelArrangement;
import org.jeecg.modules.hotel.leave.entity.LwgyHotelLeaveSchool;
import org.jeecg.modules.hotel.leave.mapper.LwgyHotelLeaveSchoolMapper;
import org.jeecg.modules.hotel.leave.service.ILwgyHotelLeaveSchoolService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @Description: 离校管理
 * @Author: jeecg-boot
 * @Date:   2023-02-14
 * @Version: V1.0
 */
@Service
public class LwgyHotelLeaveSchoolServiceImpl extends ServiceImpl<LwgyHotelLeaveSchoolMapper, LwgyHotelLeaveSchool> implements ILwgyHotelLeaveSchoolService {
    @Resource
    private LwgyHotelLeaveSchoolMapper lwgyHotelLeaveSchoolMapper;

    @Autowired
    private ILwgyHotelLeaveSchoolService lwgyHotelLeaveSchoolService;


    @Override
    public IPage<LwgyHotelLeaveSchool> queryCheckOutList(Page<LwgyHotelLeaveSchool> page, QueryWrapper<LwgyHotelLeaveSchool> queryWrapper) {

        return page.setRecords(lwgyHotelLeaveSchoolMapper.queryCheckOutList(page,queryWrapper));
    }

    @Override
    public IPage<LwgyHotelLeaveSchool> queryConfirmList(Page<LwgyHotelLeaveSchool> page, QueryWrapper<LwgyHotelLeaveSchool> queryWrapper) {

        return page.setRecords(lwgyHotelLeaveSchoolMapper.queryConfirmList(page,queryWrapper));
    }

    @Override
    public void updateStateByNum(LwgyHotelLeaveSchool lwgyHotelLeaveSchool) {
        lwgyHotelLeaveSchoolMapper.updateStateByNum(lwgyHotelLeaveSchool);
    }

    @Override
    public LwgyHotelArrangement queryStudentId(String studentNumber) {
        return lwgyHotelLeaveSchoolMapper.queryStudentId(studentNumber);
    }

    @Override
    public void updateStuState(String ids) {
        List<String> strings = Arrays.asList(ids.split(","));
        List<LwgyHotelLeaveSchool> list = new ArrayList<>();
        for (String string : strings) {
            LwgyHotelLeaveSchool lwgyHotelLeaveSchool = new LwgyHotelLeaveSchool();
            lwgyHotelLeaveSchool.setId(string);
            lwgyHotelLeaveSchool.setProcessingState("1");
            lwgyHotelLeaveSchool.setSuccessState("1");
            list.add(lwgyHotelLeaveSchool);
            System.out.println(list);
        }
        lwgyHotelLeaveSchoolService.updateBatchById(list);
    }
}
